package org.example.mulitithreading.ex9;

import java.util.concurrent.FutureTask;

public class Demo {
    public static void main(String[] args) {
        FutureTask<String> ft = new FutureTask<>(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println(Thread.currentThread().getName() + "---" + i);
            }
            return "线程执行完毕了";
        });
        Thread t1 = new Thread(ft);
        t1.setName("飞机");
        t1.setPriority(10);
        t1.start();

        FutureTask<String> ft2 = new FutureTask<>(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println(Thread.currentThread().getName() + "---" + i);
            }
            return "线程执行完毕了";
        });
        Thread t2 = new Thread(ft2);
        t2.setName("坦克");
        t2.setPriority(1);
        t2.start();
    }
}
